package com.taxi.driver.module.order.complain;

import android.content.Context;
import android.view.View;

import com.qianxx.adapter.SuperAdapter;
import com.qianxx.adapter.internal.SuperViewHolder;
import com.qianxx.utils.TypeUtils;
import com.taxi.driver.R;
import com.taxi.driver.module.vo.ComplainVO;

import java.util.ArrayList;

/**
 * 功能描述：
 */
public class OrderComplainAdapter extends SuperAdapter<ComplainVO> {

    public OrderComplainAdapter(Context context, int layoutId) {
        super(context, new ArrayList<>(), layoutId);
    }

    private int mIndex = -1;

    @Override
    public void onBind(SuperViewHolder holder, int viewType, int position, ComplainVO item) {
        holder.setText(R.id.tv_content, TypeUtils.getValue(item.tagName));
        boolean isSelect = mIndex == position;
        holder.getView(R.id.layout).setSelected(isSelect);
        holder.getView(R.id.tv_content).setSelected(isSelect);
        holder.setVisibility(R.id.iv_select, isSelect ? View.VISIBLE : View.GONE);
    }

    public void select(int position) {
        mIndex = position;
        notifyDataSetChanged();
    }

    public String getContent() {
        if (mIndex < 0) return "";
        ComplainVO vo = mList.get(mIndex);
        if (vo == null) return "";
        return TypeUtils.getValue(vo.tagName);
    }

}
